package com.geekhome.znxz.cucumber.chapter1;

import cucumber.api.PendingException;
import cucumber.api.java.en.*;
import org.junit.Assert;

/**
 * Copyright © 2019年 znxz. All rights reserved.
 *
 * @author 临江仙 hzqiuxm@163.com
 * chapter1 测试类
 * @date 2019/5/21 15:40
 */
public class Chapter1Stepdefs {

    private int result;

    private Addition addition;

    @Given("^x is (\\d+) and y is (\\d+)$")
    public void xIsAndYIs(int arg0, int arg1) throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        Assert.assertEquals(4,arg0);
        Assert.assertEquals(5,arg1);
    }

    @When("^invoke add Method$")
    public void invokeAddMethod() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        result = new Addition(4,5).add();
    }

    @Then("^the result is (\\d+)$")
    public void theResultIs(int arg0) throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        Assert.assertEquals(arg0,result);
    }

    @Given("^x is (\\d+)$")
    public void xIs(int arg0) throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        Assert.assertEquals(1,arg0);
    }

    @When("^invoke autoX Method$")
    public void invokeAutoXMethod() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        result = new Addition(1,0).autoX();
    }

    @Given("^x and y value$")
    public void xAndYValue() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        addition = new Addition(1,2);
        System.out.println("==我是background步骤，会执行多次=="+ addition);
    }

    @And("^sub operation$")
    public void subOperation() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("sub operation");
    }

    @When("^invoke calculate button$")
    public void invokeCalculateButton() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("invoke calculate button");
    }

    @Then("^the result is x-y$")
    public void theResultIsXY() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println(addition.Sub());
    }


    /**
     * but and feature test
     */


    @Given("^user open the url and git$")
    public void userOpenTheUrlAndGit() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("user open the url and git");
    }

    @And("^user open the url for jenkins$")
    public void userOpenTheUrlForJenkins() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("user open the url for jenkins");
    }

    @When("^click build job link$")
    public void clickBuildJobLink() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("click build job link");
    }

    @Then("^the job will be start$")
    public void theJobWillBeStart() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("the job will be start");
    }

    @When("^click the job id link$")
    public void clickTheJobIdLink() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("click the job id link");
    }

    @And("^choice the job console$")
    public void choiceTheJobConsole() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("choice the job console");
    }

    @And("^goto the job page$")
    public void gotoTheJobPage() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("oto the job page");
    }

    @Then("^the job building log will be print$")
    public void theJobBuildingLogWillBePrint() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("the job building log will be print");
    }

    @And("^the last job can see successfully state$")
    public void theLastJobCanSeeSuccessfullyState() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("the last job can see successfully state");
    }

    @But("^the job will not running at current$")
    public void theJobWillNotRunningAtCurrent() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        System.out.println("the job will not running at current");
    }





}
